import { LordCardObject } from "@/types/game/card";
import { GameEvent, GamePlayerEvent } from "@/types/game/event";
import { Player } from "@/types/game/player";
import { lordCardList } from "./card-list";
const eventCreatorList = {
    playerUseLordCard: (player: Player, lordCardName: string): GamePlayerEvent => ({
        name: 'playerUseLordCard',
        data: {
            player,
            lordCardName
        },
        async action() {
            const lordCard: LordCardObject = lordCardList[lordCardName];
            for (const stateName in lordCard.states) {
                player.states.push(lordCard.states[stateName]);
            }
            for (const tokenName in lordCard.tokens) {
                player.tokens[tokenName] = lordCard.tokens[tokenName];
            }
            for (const effect of lordCard.effects) {
                effect(player);
            }
        },
    }),
    playerStartAction: (player: Player): GamePlayerEvent => {
        return {
            name: 'playerStartAction',
            data: {
                player
            },
            async action(eventData, gameData, gameAction, eventManager) {
                player.isAi ? eventManager.addEventUseCreator('playerChooseActionAsAI', player) :
                    eventManager.addEventUseCreator('playerChooseAction', player)
            },
        }
    },
    playerChooseActionAsAI: (player: Player): GamePlayerEvent => {
        return {
            name: 'playerChooseActionAsAI',
            data: {
                player
            },
        }
    },
    playerChooseAction: (player: Player): GamePlayerEvent => {
        return {
            name: 'playerChooseAction',
            data: {
                player
            },
        }
    }
}
export default eventCreatorList